home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue39 / slimmer / TrimMem.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-09-11  |  723 b   |  33 lines

  1. unit TrimMem;
  2. //
  3. // Code courtesy of Roy Nelson (rnelson@inprise.com),
  4. // Inprise European Professional Support
  5. //
  6. // Call TrimWorkingSet from you project file or from a package
  7. // to reduce the memory overhead - note that this will only work
  8. // on Windows NT.
  9. //
  10. // From Delphi Magazine article "Slimming the fat off your Apps"
  11. // by Hallvard Vassbotn, hallvard@falcon.no
  12. //
  13. interface
  14.  
  15. procedure TrimWorkingSet;
  16.  
  17. implementation
  18.  
  19. uses
  20.   Windows,
  21.   SysUtils;
  22.  
  23. procedure TrimWorkingSet;
  24. var
  25.   MainHandle : THandle;
  26. begin
  27.  MainHandle := OpenProcess(PROCESS_ALL_ACCESS, false, GetCurrentProcessID);
  28.  SetProcessWorkingSetSize(MainHandle,DWORD(-1),DWORD(-1));
  29.  CloseHandle(MainHandle);
  30. end;
  31.  
  32. end.
  33.